/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test_system.questions;

/**
 *
 * @author root
 */
public class CheckAnswerQuestion extends Question {
    Answer[] answerVars;
    
    public CheckAnswerQuestion(String questionBody, Answer[] answerVars){
        this.questionBody = questionBody;
        this.answerVars = answerVars;
    }
    
    public Answer getVarById(int i){
        return answerVars[i];
    }

    @Override
    public String toString() {
        StringBuffer res = new StringBuffer();
        res.append("\n" + questionBody );
        for(int i = 0; i < answerVars.length; i++){
            res.append("\n" + (i+1) + ")");
            res.append(answerVars[i]);
        }
        return res.toString();
    }

    @Override
    public Answer getRightAnswer() {
        for(Answer answer : answerVars){
            if(answer.isRight()){
                return answer;
            }
        }
        return answerVars[0];
    }


}
